import { EzFormControlComponent } from '../ez-form-control';
import { EzTextareaConfiguration } from './ez-textarea.configuration';
import { EzTextarea } from './ez-textarea';
import { OnInit, OnDestroy, Component } from '@angular/core';
import { EzFormItemComponent } from '../ez-form-item';
import { EzFormGroupComponent } from '../ez-form-group';
import { EzFormComponent } from '../ez-form';
@Component({
  selector: 'ez-textarea',
  templateUrl: './ez-textarea.component.html',
  styleUrls: ['./ez-textarea.component.less'],
  providers: [{ provide: EzFormControlComponent, useExisting: EzTextareaComponent }],
})
export class EzTextareaComponent extends EzFormControlComponent<EzTextareaConfiguration, string>
  implements EzTextarea, OnInit, OnDestroy {
  defaultMaxlength = Infinity;

  defaultRows = Infinity;

  constructor(
    protected ezForm: EzFormComponent,
    protected ezFormGroup: EzFormGroupComponent,
    protected ezFormItem: EzFormItemComponent
  ) {
    super(ezForm, ezFormGroup, ezFormItem);
  }

  ngOnInit(): void {
    super.ngOnInit();
  }

  checkConfiguration(configuration: EzTextareaConfiguration): void {}

  onBlur(event: KeyboardEvent): void {
    if (this.ezFormControlConfiguration.onBlur) {
      this.ezFormControlConfiguration.onBlur(this, this.ezFormGroup, this.ezForm);
    }
  }

  onFocus(event: KeyboardEvent): void {
    if (this.ezFormControlConfiguration.onFocus) {
      this.ezFormControlConfiguration.onFocus(this, this.ezFormGroup, this.ezForm);
    }
  }
}
